package com.tbit.uqbike.object.view.sugar.ride;

import com.tbit.uqbike.object.pojo.RideLog;
import com.tbit.uqbike.object.view.sugar.AsteriskUtils;
import com.tbit.uqbike.object.view.sugar.SugarTableData;
import com.tbit.uqbike.object.view.sugar.SugarTableItem;
import com.tbit.utils.DateUtil;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * @author MyWin E-mail:335918956@qq.com
 * @version 1.0
 * @createTime 2020-01-06 19:36
 * 骑行记录
 * 车辆编号、用户手机号（需要只显示开始和结束中间用*代替）、骑行开始时间、骑行里程、扣费金额
 */
public class SugarRideInfo extends SugarTableItem {
    public static final String PRO_USER_CODE = "userCode";
    public static final String PRO_PHONE = "phone";
    public static final String PRO_START_DT = "startRideDt";
    public static final String PRO_END_DT = "endRideDt";
    public static final String PRO_RIDE_MILE = "rideMile";
    public static final String PRO_FEE = "fee";
    public static List<SugarTableData.Columns> COLS;
    private static DecimalFormat df = new DecimalFormat("#.##");

    static {
        COLS = new ArrayList() {
            {
                add(new SugarTableData.Columns(PRO_USER_CODE, PRO_USER_CODE));
                add(new SugarTableData.Columns(PRO_PHONE, PRO_PHONE));
                add(new SugarTableData.Columns(PRO_START_DT, PRO_START_DT));
                add(new SugarTableData.Columns(PRO_END_DT, PRO_END_DT));
                add(new SugarTableData.Columns(PRO_RIDE_MILE, PRO_RIDE_MILE, "km"));
                add(new SugarTableData.Columns(PRO_FEE, PRO_FEE, "元"));
            }
        };
    }

    public String userCode;
    public String phone;
    public String startRideDt;
    public String endRideDt;
    public String rideMile;
    public String fee;

    public SugarRideInfo(RideLog rl) {
        this.userCode = rl.getUserCode();
        this.phone = rl.getPhone();
        this.startRideDt = DateUtil.MDHMS_.format(rl.getStartTime());
        this.endRideDt = DateUtil.MDHMS_.format(rl.getEndTime());
        this.rideMile = rl.getMileage().toString();
        this.fee = df.format(rl.getMoney() / 100.0);
    }

    public void asterisk() {
        this.userCode = AsteriskUtils.handle(this.userCode, 2, 3);
        this.phone = AsteriskUtils.handle(this.phone, 2, 4);
    }

}
